import 'package:flutter/material.dart';

//根据现有空间，来调整child的尺寸
class FractionallySizedBoxWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: new AppBar(
          title: new Text("FractionallySizedBox"),
          leading: new BackButton(),
        ),
        body: new Container(
          color: Colors.blue,
          height: 150,
          width: 150,
          padding: const EdgeInsets.all(10),
          /*当设置了具体的宽高因子，具体的宽高则根据现有空间宽高 * 因子，有可能会超出父控件的范围，当宽高因子大于1的时候；
           *当没有设置宽高因子(null)，则填满可用区域；*/
          child: new FractionallySizedBox(
            alignment: Alignment.topLeft,
            widthFactor: 1.5,
            heightFactor: 0.5,
            child: new Container(
              color: Colors.red,
            ),
          ),
        ));
  }
}
